<?php
class forum_cardsMod extends commonMod
{
    public function __construct()
    {
        parent::__construct();
    }

    public function index(){
        //分页信息
        $listRows=5;
        $url = __URL__ . '/index/page-{page}.html'; //分页基准网址
        $limit=$this->pagelimit($url,$listRows);
        //内容列表          
        //查询数据库表forum_cards_bbs所有字段  【获取模块】
        $list=$this->model->table("forum_cards_bbs")->order(" id desc ")->limit($limit)->select();
       //forum_bbs“模块”关联forum_cards_bbs
        if ($list){
        	foreach ($list as $k=>$v){
        		$forum=$this->model->table('forum_bbs')->where(" id = '".$v['forum_id']."' ")->find();
        		//dump($forum);
        		$list[$k]['forum_name'] = $forum['forum_name'];
        		unset($forum);
        	}
        }
        foreach ( $list as $key => $value ) {
        	if($list [$key] ['forum_type']==2){
        		$list [$key] ['type_name'] = "热门";
        	}
        	if ($list [$key] ['forum_type']==1){
        		$list [$key] ['type_name'] = "精华";
        	}
        	if ($list [$key] ['forum_type']==0){
        		$list [$key] ['type_name'] = "普通";
        	}
        }
        $this->list = $list;
        $this->time = $time;
        $count=$this->model->table("forum_cards_bbs")->count();
        $this->page=$this->page($url, $count, $listRows); 
        $this->show();
    }
    public function add(){	
    	$list = $this->model->table("forum_bbs")->select();
    	$this->assign("list", $list);
    	$this->show();
    }

    public function act_add(){
    	$data = $_POST;
    	$data['release_time'] = time();
    	$this->model->table("forum_cards_bbs")->data($data)->insert();    	
        $this->msg('添加成功！',1);
    }

    public function edit(){
    	$id = $_GET['id'];
    	$this->info = $this->model->table("forum_cards_bbs")->where(" id = '".$id."' ")->find();
    	$list = $this->model->table("forum_bbs")->select();
    	$this->assign("list", $list);
    	$this->show();
    }

   public function act_edit(){
      $data = $_POST;
  //    $data['last_time'] = time();
   //  $this->model->table("forum_bbs")->where(" id = '".$_POST['id']."' ")->select();
      $this->model->table("forum_cards_bbs")->where(" id = '".$_POST['id']."' ")->data($data)->update();
      $this->msg('添加成功！',1);
    }

    public function del(){
    	$id=intval($_POST['id']);
        $this->alert_str($id,'int',true);        
        $status=$this->model->table("forum_cards_bbs")->where(" id = '".$id."' ")->delete();
        
        $this->msg('删除成功！',1);
    }
    public function forum_reply(){
    	$id = $_GET['id'];
    	$this->list = $this->model->table("forum_reply_bbs")->where("cards_id  = '".$id."' ")->select();
    	dump($this->info );
  // $data = $_POST;
   //$data['last_time'] = time();
  // $this->model->table("forum_cards_bbs")->where(" id = '".$_POST['id']."' ")->select();
    	$this->show();
    	// $data['order_time'] = time();
    }

     /*   public function reply_add(){
     	$list = $this->model->table("forum_reply_bbs")->select();
    	$this->assign("list", $list);
    	$this->show();
    }
    
    public function reply_act_add(){
    	$data = $_POST;
    	$data['release_time'] = time();
    	$this->model->table("forum_reply_bbs")->data($data)->insert();
    	$this->msg('添加成功！',1);
    }
    
    public function reply_edit(){
    	$id = $_GET['id'];
    	$this->info = $this->model->table("forum_reply_bbs")->where(" id = '".$id."' ")->find();
    	$list = $this->model->table("forum_bbs")->select();
    	$this->assign("list", $list);
    	$this->show();
    }
    
    public function reply_act_edit(){
    	$data = $_POST;
    	//    $data['last_time'] = time();
    	//  $this->model->table("forum_bbs")->where(" id = '".$_POST['id']."' ")->select();
    	$this->model->table("forum_reply_bbs")->where(" id = '".$_POST['id']."' ")->data($data)->update();
    	$this->msg('添加成功！',1);
    }
    
    public function reply_del(){
    	$id=intval($_POST['id']);
    	$this->alert_str($id,'int',true);
    	$status=$this->model->table("forum_reply_bbs")->where(" id = '".$id."' ")->delete();
    
    	$this->msg('删除成功！',1);
    }
*/
}
?>